<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for src/assets/octopus/engine/template.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="..\..\..\..\prettify.css" />
    <link rel="stylesheet" href="..\..\..\..\base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(..\..\..\..\sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="..\..\..\..\index.html">All files</a> / <a href="index.html">src/assets/octopus/engine</a> template.js
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/35</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/12</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/11</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/35</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">function <span class="fstat-no" title="function not covered" >oTemplateEngine(engine) {</span>
<span class="cstat-no" title="statement not covered" >  this.engine = engine;</span>
}
&nbsp;
oTemplateEngine.prototype = {
  // 此处的渲染是通过App.vue的$nextTick调用，一定是vue+前端脚本都执行完才会处理的，相当保险。
  render: <span class="fstat-no" title="function not covered" >function () </span>{
    // debugger
    let o = <span class="cstat-no" title="statement not covered" >this;</span>
    // 检索八爪鱼容器对象
    let oContainerDom = <span class="cstat-no" title="statement not covered" >$("div [o-Container]");</span>
    // 八爪鱼容器在一个页面，只允许出现一次，因为模板也只有一个对应。
<span class="cstat-no" title="statement not covered" >    if (oContainerDom.length == 1) {</span>
      // 取得容器的Jquery对象。
      let o_Container = <span class="cstat-no" title="statement not covered" >$(oContainerDom.get(0));</span>
<span class="cstat-no" title="statement not covered" >      if (o_Container.attr("o-Container") != "true") {</span>
        // 尝试渲染模板
        let tmpPath = <span class="cstat-no" title="statement not covered" >"/static/skin/" + this.getTheme().name + this.engine.router.get().path + "/template.html";</span>
<span class="cstat-no" title="statement not covered" >        $.ajax({</span>
          type: "GET",
          cache: false,
          url: tmpPath,
          data: "",
          complete: <span class="fstat-no" title="function not covered" >function (</span>data) {
            // console.log("KKKKK-------"+tmpPath);
            // 认为地址不存在，模版页中不会存在HTML
<span class="cstat-no" title="statement not covered" >            if (JSON.stringify(data).indexOf("&lt;html") &gt; -1) {</span>
              // 设置为默认模版
<span class="cstat-no" title="statement not covered" >              tmpPath = "/static/skin/default/engine/base/default/template.html";</span>
              // console.log("KKKKKK======="+data.toString().indexOf("html"));
            }
            // console.log("KKKKKK:::"+JSON.stringify(data));
            // 调用八爪鱼Request引擎请求HTML模板资源
<span class="cstat-no" title="statement not covered" >            o.getHtml(tmpPath, o_Container);</span>
          }
        });
      } else {
<span class="cstat-no" title="statement not covered" >        this.engine.tips.info("八爪鱼已渲染过该页，再次进入本页，可在此写入适当的更新脚本。");</span>
      }
    } else {
<span class="cstat-no" title="statement not covered" >      this.engine.tips.warning("八爪鱼渲染框架未找到容器标记。")</span>
    }
&nbsp;
    // $.getScript('index.js',function () {
    //   console.log("内部JS文件加载成功。");
    // });
&nbsp;
<span class="cstat-no" title="statement not covered" >    this.engine.tips.debug("[template] 八爪鱼渲染模版成功。");</span>
  },
  getHtml: <span class="fstat-no" title="function not covered" >function (</span>path, container) {
    let o = <span class="cstat-no" title="statement not covered" >this;</span>
    // 确认找到渲染数据，然后设置为true，下次进来，则不会渲染，不管Ajax是否请求到，只请求一次，否则next和update会冲突。
<span class="cstat-no" title="statement not covered" >    container.attr("o-Container", true);</span>
<span class="cstat-no" title="statement not covered" >    this.engine.request.getHTML(path, <span class="fstat-no" title="function not covered" >function (</span>data) {</span>
      // 采用Jquery的方式才能加载使用js，而且内嵌js不会报错。
<span class="cstat-no" title="statement not covered" >      container.append(data);</span>
<span class="cstat-no" title="statement not covered" >      container.find("[o-id]").each(<span class="fstat-no" title="function not covered" >function (</span>index, item) {</span>
        //$(item).append($("#" + $(item).attr("o-id")));
        // const 常量：不可改变、常驻内存。
        let oid = <span class="cstat-no" title="statement not covered" >$(item).attr("o-id");</span>
        let oControl = <span class="cstat-no" title="statement not covered" >$("#" + oid);</span>
<span class="cstat-no" title="statement not covered" >        if (oControl.length == 1) {</span>
<span class="cstat-no" title="statement not covered" >          $(item).html(oControl);</span>
        } else {
<span class="cstat-no" title="statement not covered" >          o.engine.tips.warning("渲染引擎未找到目标组件：id=" + oid + "。")</span>
        }
      });
    }, <span class="fstat-no" title="function not covered" >function (</span>msg) {
      // 找不到设置模版，则采用默认模版地址
<span class="cstat-no" title="statement not covered" >      o.engine.tips.debug("渲染模板异常，状态" + msg.status + "，描述：" + msg.statusText + "，模版地址：" + msg.url + "。");</span>
    });
  },
  getTheme: <span class="fstat-no" title="function not covered" >function () </span>{
    let <span class="cstat-no" title="statement not covered" >theme;</span>
<span class="cstat-no" title="statement not covered" >    $(this.engine.passport.theme).each(<span class="fstat-no" title="function not covered" >function (</span>index, item) {</span>
<span class="cstat-no" title="statement not covered" >      if (item.use) {</span>
<span class="cstat-no" title="statement not covered" >        theme = item;</span>
<span class="cstat-no" title="statement not covered" >        return false;</span>
      }
    });
<span class="cstat-no" title="statement not covered" >    return theme;</span>
  },
  choiceTheme: <span class="fstat-no" title="function not covered" >function (</span>name) {
<span class="cstat-no" title="statement not covered" >    $(this.engine.passport.theme).each(<span class="fstat-no" title="function not covered" >function (</span>index, item) {</span>
      // 找到选中的进行数据修改。
<span class="cstat-no" title="statement not covered" >      if (item.name == name) {</span>
<span class="cstat-no" title="statement not covered" >        item.use = true;</span>
      } else {
<span class="cstat-no" title="statement not covered" >        item.use = false;</span>
      }
    })
  }
}
&nbsp;
export {
  oTemplateEngine
}
&nbsp;
&nbsp;
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Jan 20 2020 17:54:15 GMT+0800 (GMT+08:00)
</div>
</div>
<script src="..\..\..\..\prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="..\..\..\..\sorter.js"></script>
</body>
</html>
